

import 'dart:ui';

import 'package:baselib/utils/color_base_util.dart';
import 'package:baselib/utils/px_base_util.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'gradient_card_view.dart';

class DialogUtil {
  static final DialogUtil _singleton = DialogUtil._internal();

  static DialogUtil get instance => DialogUtil();


  factory DialogUtil() {
    return _singleton;
  }

  DialogUtil._internal(){
    //做一些操作

  }
  Future<T> showCommBottomSheet<T>({Widget child}) async {
    return await showModalBottomSheet<T>(
      isScrollControlled: true, // required for min/max child size
      context: Get.context,
      barrierColor: Colors.transparent,
      backgroundColor: const Color(0x33ffffff),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(PxBaseUtil().px_30),
          topRight: Radius.circular(PxBaseUtil().px_30),
        ),
      ),
      clipBehavior: Clip.antiAlias,
      builder: (ctx) {
        return AnimatedPadding(
          padding: MediaQuery.of(Get.context).viewInsets,
          duration: const Duration(milliseconds: 100),
          child: ClipRect(
            child: BackdropFilter(
              // blendMode: BlendMode.softLight,
              filter: ImageFilter.blur(
                sigmaX: PxBaseUtil().px_20,
                sigmaY: PxBaseUtil().px_20,
              ),
              child: GradientCardView(
                margin: EdgeInsets.only(),
                outPadding: EdgeInsets.only(
                    top: PxBaseUtil().px_1
                ),
                width: PxBaseUtil().screenWidth,
                backGroundColor: ColorBaseUtil().color_2F4072,
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(PxBaseUtil().px_30),
                  topRight: Radius.circular(PxBaseUtil().px_30),
                ),
                child: child,
              ),
            ),
          ),
        );
      },
    );
  }
  Future<T> showBottomSheet<T>({Widget child}) async {
    return await showModalBottomSheet<T>(
      isScrollControlled: true, // required for min/max child size
      context: Get.context,
      barrierColor: Colors.transparent,
      backgroundColor: const Color(0x33ffffff),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(PxBaseUtil().px_30),
          topRight: Radius.circular(PxBaseUtil().px_30),
        ),
      ),
      clipBehavior: Clip.antiAlias,
      builder: (ctx) {
        return AnimatedPadding(
          padding: MediaQuery.of(Get.context).viewInsets,
          duration: const Duration(milliseconds: 100),
          child: ClipRect(
            child: BackdropFilter(
              // blendMode: BlendMode.softLight,
              filter: ImageFilter.blur(
                sigmaX: PxBaseUtil().px_20,
                sigmaY: PxBaseUtil().px_20,
              ),
              child: child,
            ),
          ),
        );
      },
    );
  }
}